import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    { path: '/', redirect: '/login' },
    {
      path: '/manager',
      component: () => import('@/views/Manager.vue'),
      children: [
        { path: 'home', meta: { name: '系统首页' }, component: () => import('@/views/manager/Home.vue'),  },
        { path: 'admin', meta: { name: '管理员信息' }, component: () => import('@/views/manager/Admin.vue'), },
        { path: 'user', meta: { name: '用户信息' }, component: () => import('@/views/manager/User.vue'), },
        { path: 'notice', meta: { name: '系统公告' }, component: () => import('@/views/manager/Notice.vue'), },
        { path: 'person', meta: { name: '个人资料' }, component: () => import('@/views/manager/Person.vue'), },
        { path: 'password', meta: { name: '修改密码' }, component: () => import('@/views/manager/Password.vue'), },
        { path: 'category', meta: { name: '歌曲分类' }, component: () => import('@/views/manager/Category.vue'), },
        { path: 'singer', meta: { name: '歌手信息' }, component: () => import('@/views/manager/Singer.vue'), },
        { path: 'album', meta: { name: '专辑信息' }, component: () => import('@/views/manager/Album.vue'), },
        { path: 'sing', meta: { name: '歌曲信息' }, component: () => import('@/views/manager/Sing.vue'), },
        { path: 'playlist', meta: { name: '歌单信息' }, component: () => import('@/views/manager/Playlist.vue'), },
        { path: 'collect', meta: { name: '收藏信息' }, component: () => import('@/views/manager/Collect.vue'), },
        { path: 'comment', meta: { name: '评论信息' }, component: () => import('@/views/manager/Comment.vue'), },
        { path: 'carousel', meta: { name: '轮播图信息' }, component: () => import('@/views/manager/Carousel.vue'), },
      ]
    },
    {
      path: '/front',
      component: () => import('@/views/Front.vue'),
      children: [
        { path: 'home', component: () => import('@/views/front/Home.vue'),  },
        { path: 'person', component: () => import('@/views/front/Person.vue'),  },
        { path: 'password', component: () => import('@/views/front/Password.vue'),  },
        { path: 'myPlaylist', component: () => import('@/views/front/MyPlaylist.vue'),  },
        { path: 'myCollect', component: () => import('@/views/front/MyCollect.vue'),  },
        { path: 'myComment', component: () => import('@/views/front/MyComment.vue'),  },
        { path: 'album', component: () => import('@/views/front/Album.vue'),  },
        { path: 'albumDetail', component: () => import('@/views/front/AlbumDetail.vue'),  },
        { path: 'playlist', component: () => import('@/views/front/PlayList.vue'),  },
        { path: 'playlistDetail', component: () => import('@/views/front/PlaylistDetail.vue'),  },
        { path: 'singer', component: () => import('@/views/front/Singer.vue'),  },
        { path: 'singerDetail', component: () => import('@/views/front/SingerDetail.vue'),  },
        { path: 'song', component: () => import('@/views/front/Song.vue'),  },
        { path: 'songDetail', component: () => import('@/views/front/SongDetail.vue'),  },
        { path: 'hot', component: () => import('@/views/front/Hot.vue'),  },
      ]
    },
    { path: '/login', component: () => import('@/views/Login.vue') },
    { path: '/register', component: () => import('@/views/Register.vue') },
    { path: '/404', component: () => import('@/views/404.vue') },
    { path: '/:pathMatch(.*)', redirect: '/404' }
  ]
})

router.afterEach(() => {
  setTimeout(() => {
    window.scrollTo({top: 0, behavior: 'smooth'})
  }, 0)
})

export default router
